def init_test_member(session):
    from mall.models.member import Member
    import random
    from mall.models.resource import Resource
    from mall.models.currency import Currency
    from mall.models.account import Account
    session.query(Member).delete()
    session.query(Account).delete()
    resource_list = session.query(Resource).all()
    currency_list = session.query(Currency).all()
    for i in range(0, 9):
        member_id = 'dealer_{}'.format(i)

        member = Member(
            id=member_id,
            screen_name=member_id,
            deal_count=random.randint(1000, 99999),
            seller_score=random.choice(range(1, 5)),
            buyer_score=random.choice(range(1,5)),

            head_image_id=random.choice(resource_list).id,
        )

        account_id = '1-{}'.format(str(i).zfill(15))

        account = Account(
            id=account_id,
            balance=0,
            reward_amount=0,
            frozen_amount=0,
            pending_amount=0,
            currency_id=random.choice(currency_list).id
        )
        member.account = account

        session.add(member)
    session.commit()
